package org.example.enmus;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import me.zhyd.oauth.request.AuthGiteeRequest;
import me.zhyd.oauth.request.AuthGithubRequest;
import me.zhyd.oauth.request.AuthRequest;
import org.example.domain.dto.GiteeAuthResponse;
import org.example.domain.dto.GithubAuthResponse;

@Getter
@RequiredArgsConstructor
public enum SocialAuthEnum {

    GITEE("1", "gitee", AuthGiteeRequest.class, GiteeAuthResponse.class),
    GITHUB("2", "github", AuthGithubRequest.class, GithubAuthResponse.class),
    ;

    private final String code;

    private final String key;
    
    private final Class<? extends AuthRequest> clazz;

    private final Class<?> resposeClass;

    public static String getKeyByCode(String code) {
        if (StrUtil.isBlank(code)) {
            return null;
        }
        for (SocialAuthEnum authEnum : values()) {
            if (authEnum.getCode().equals(code)) {
                return authEnum.getKey();
            }
        }
        return null;
    }

    public static SocialAuthEnum getSocialEnum(String code) {
        if (StrUtil.isBlank(code)) {
            return null;
        }
        for (SocialAuthEnum anEnum : values()) {
            if (anEnum.getCode().equals(code)) {
                return anEnum;
            }
        }
        return null;
        
    }
    
}
